home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Gamer (Italian) 30
/
PC Gamer IT CD 30 1-2.iso
/
MOTS
/
GAMEDATA
/
RESOURCE
/
JKMRES.GOO
/
cog_weap_stscope_m.cog
< prev
next >
Wrap
Text File
|
1998-02-25
|
11KB
|
483 lines
# Jedi Knight Cog Script
#
# WEAP_STRIFLE.COG
#
# WEAPON 13 script - Stormtrooper Rifle
#
# The standard rifle used by the stormtroopers. Not as accurate as the Bryar Pistol.
# This weapon has only one type of fire.
#
# - Affected by MagSealed sectors/surfaces.
#
# [YB & CYW]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved
symbols
model povModel=nullpov.3do local
model weaponMesh=sscg.3do local
keyframe mountAnim=sscVmnt.key local
keyframe dismountAnim=sscVdis.key local
keyframe povfireAnim=sscVpst1.key local
keyframe holsterAnim=schlstr.key local
sound mountSound=df_rif_ready.wav local
sound dismountSound=PutWeaponAway01.wav local
sound fireSound=trprsht2.wav local
sound outSound=trprout.wav local
template projectile=+sclaser local
thing player local
thing lookthing local
flex fireWait=0.5 local
flex holsterWait local
flex powerBoost local
flex autoAimFOV=0.1 local
flex magnification=4.0 local
flex tempflex local
int iZoomPoint=1 local
flex fZoomTable=0.0 local
flex fZoomTable1=4.0 local
flex fZoomTable2=11.0 local
flex fZoomTable3=23.0 local
flex fZoomTable4=0.0 local
int dummy local
int trackID=-1 local
int fireChannel=-1 local
int holsterTrack local
int mode local
int manualMode=0 local
int greenEffectHandle=-1 local
int modeSwitchDown=0 local
message newplayer
message shutdown
message playeraction
message activated
message deactivated
message selected
message deselected
message autoselect
message fire
message timer
message pulse
message killed
end
# ========================================================================================
code
newplayer:
if (greenEffectHandle != -1)
{
freeColorEffect(greenEffectHandle);
greenEffectHandle = -1;
}
SetCameraZoom(0, 1.0, 500.0);
ClearActorFlags(GetLocalPlayerThing(), 0x20000000);
return;
fire:
player = GetSourceRef();
mode = GetSenderRef();
// Don't do anything in mode 1.
if (mode == 1)
return;
// Check that the player is still alive.
if(GetThingHealth(player) <= 0)
{
Return;
}
// The player may want to use the scope even if they
// don't have ammo for it, so don't autoswitch away.
// Check Ammo - If we are out, autoselect best weapon.
// It should always use two energy cells, but -- as in DF --
// allow the last fire if there is only one left...
// if(GetInv(player, 11) < 1.0)
// {
// PlaySoundThing(outSound, player, 1.0, -1, -1, 0x80);
// if((GetAutoSwitch() & 1))
// SelectWeapon(player, GetWeaponBin(AutoSelectWeapon(player, 1)));
// Return;
// }
// Only fire if we have the ammo.
if(GetInv(player, 11) > 1.0)
{
// SetPOVShake('0.0 -.003 0.0', '1.5 0.0 0.0', .05, 80.0);
SendMessageEx(GetThingClassCog(GetLocalPlayerThing()), user1, 3, 0, 0, 0);
// If this is the scout, double the damage and make no sound.
if (jkGetMultiParam (0) == 3)
dummy = FireProjectile(player, projectile, -1, -1, '0.0 0.0 0.035', '0 0 0', 2.0, 0x2, autoAimFOV, autoAimFOV);
else
dummy = FireProjectile(player, projectile, fireSound, -1, '0.0 0.0 0.035', '0 0 0', 1.0, 0x0, autoAimFOV, autoAimFOV);
ChangeInv( player, 11, -4.0 );
// jkPlayPOVKey( player, povfireAnim, 1, 0x38 );
powerBoost = GetInv(player, 63);
ChangeFireRate(player, fireWait/powerBoost);
}
Return;
# ........................................................................................
activated:
player = GetSourceRef();
mode = GetSenderRef();
if (mode == 1)
{
manualMode = 1 - manualMode;
// Capture jump and crouch.
if (manualMode == 1)
{
magnification = fZoomTable[iZoomPoint];
SetCameraZoom(0, magnification, 150.0);
SetActionCog(GetSelfCog(), 0x4083);
jkPrintUNIString(player, 386); // Manual Zoom Mode
}
else
{
SetActionCog(GetSelfCog(), 0x4080);
jkPrintUNIString(player, 385); // Automatic Zoom Mode
}
modeSwitchDown = 1;
}
else
{
jkSetWaggle(player, '0.0 0.0 0.0', 0);
powerBoost = GetInv(player, 63);
ActivateWeapon(player, fireWait/powerBoost, mode);
}
Return;
# ........................................................................................
deactivated:
mode = GetSenderRef();
if (mode == 1)
{
modeSwitchDown = 0;
return;
}
player = GetSourceRef();
jkSetWaggle(player, '10.0 7.0 0.0', 350);
DeactivateWeapon(player, mode);
Return;
# ........................................................................................
selected:
player = GetSourceRef();
PlayMode(player, 41);
PlaySoundThing(mountSound, player, 1.0, -1, -1, 0x80);
jkSetPOVModel(player, povModel);
SetArmedMode(player, 1);
jkSetWeaponMesh(player, weaponMesh);
jkSetWaggle(player, '10.0 7.0 0.0', 350);
trackID = jkPlayPOVKey(player, mountAnim, 0, 20);
SetMountWait(player, GetKeyLen(mountAnim));
jkClearFlags(player, 0x5);
SetCurWeapon(player, GetWeaponBin(13));
if (greenEffectHandle != -1)
{
freeColorEffect(greenEffectHandle);
greenEffectHandle = -1;
}
greenEffectHandle = newColorEffect(1.0, 0, 0, 0, 0, 0, 0, 0, 0, 1.0);
EnableIRMode(0.3, 1);
// Go to primary view.
SetCurrentCamera(0);
// Turn on Scope hud.
SetActorFlags(player, 0x20000000);
// Turn on zoom
if (!manualMode)
{
jkPrintUNIString(player, 385); // Automatic Zoom Mode
SetActionCog(GetSelfCog(), 0x4080);
iZoomPoint = 1;
magnification=fZoomTable[iZoomPoint];
SetPulse(0.25);
}
else
{
jkPrintUNIString(player, 386); // Manual Zoom Mode
SetActionCog(GetSelfCog(), 0x4083);
}
if (GetCurWeapon(player) == 13)
SetCameraZoom(0, magnification, 500.0);
Return;
# ........................................................................................
deselected:
player = GetSourceRef();
if (greenEffectHandle != -1)
{
freeColorEffect(greenEffectHandle);
greenEffectHandle = -1;
}
// Turn off Scope hud.
ClearActorFlags(player, 0x20000000);
PlaySoundThing(dismountSound, player, 1.0, -1, -1, 0x80);
jkPlayPOVKey(player, dismountAnim, 0, 18);
holsterWait = GetKeyLen(holsterAnim);
SetMountWait(player, holsterWait);
holsterTrack = PlayKey(player, holsterAnim, 1, 0x4);
SetTimerEx(holsterWait, 2, 0.0, 0.0);
if (trackID != -1)
{
jkStopPOVKey(player, trackID, 0);
trackID = -1;
}
jkSetWaggle(player, '0.0 0.0 0.0', 0);
// Don't disable IR mode if IR Goggles are on...
if (
!IsInvActivated(player, 41) &&
!IsInvActivated(player, 23)
)
DisableIRMode();
// Turn off zoom
SetPulse(0.0);
SetCameraZoom(0, 1.0, 500.0);
SetActionCog(-1, 0);
Return;
# ........................................................................................
autoselect:
player = GetSourceRef();
// If the player has both the rifle and the scope...
if (
(GetInv(player, GetWeaponBin(3)) != 0.0) &&
(GetInv(player, GetWeaponBin(13)) != 0.0)
)
{
// If the player has ammo
if(GetInv(player, 11) != 0.0)
{
ReturnEx(550.0);
}
else
{
// You can still arm with no ammo, it's just a very low priority.
ReturnEx(1.0);
}
}
else
{
ReturnEx(-1.0);
}
// Scope doesn't work in the temple.
if (GetInv(player, 93) > 0.0)
ReturnEx(-1.0);
Return;
# ........................................................................................
timer:
StopKey(player, holsterTrack, 0.0);
Return;
# ........................................................................................
playeraction:
if (GetCurWeapon(GetLocalPlayerThing()) != 13)
{
SetActionCog(-1, 0);
return;
}
if (manualMode == 1)
{
if (GetParam(0) == 0.0) // Jump
{
if (GetParam(2) == 1.0)
{
iZoomPoint = iZoomPoint + 1;
if (fZoomTable[iZoomPoint] != 0.0)
{
magnification = fZoomTable[iZoomPoint];
if (magnification < 4.0)
magnification = 4.0;
else if (magnification > 23.0)
magnification = 23.0;
SetCameraZoom(0, magnification, 150.0);
}
else
{
iZoomPoint = iZoomPoint - 1;
}
}
}
if (GetParam(0) == 1.0) // Crouch
{
if (GetParam(2) == 1.0)
{
iZoomPoint = iZoomPoint - 1;
if (fZoomTable[iZoomPoint] != 0.0)
{
magnification = fZoomTable[iZoomPoint];
if (magnification < 4.0)
magnification = 4.0;
else if (magnification > 23.0)
magnification = 23.0;
SetCameraZoom(0, magnification, 150.0);
}
else
{
iZoomPoint = iZoomPoint + 1;
}
}
}
}
// if (GetParam(0) == 2.0) // Activate
// {
// manualMode = 1 - manualMode;
//
// if (manualMode)
// SetPulse(0.0);
// else
// SetPulse(0.25);
// }
if (GetParam(0) == 7.0) // Select Weapon
{
if (!modeSwitchDown) // Don't allow weapon switches if
{ // Secondary fire is active.
ReturnEx(1.0);
return;
}
}
if (GetParam(0) == 14.0) // Other action
{
if (GetParam(2) != 0.0) // Everything is OK except cycle camera.
{
ReturnEx(1.0);
return;
}
}
ReturnEx(0.0);
return;
# ........................................................................................
pulse:
if (GetCurWeapon(GetLocalPlayerThing()) == 13)
if (manualMode == 0)
{
lookthing = FirstThingInView(player, 10, 100, 0x404);
if (lookthing && (lookthing != -1))
{
tempflex = VectorDist(GetThingPos(lookthing), GetThingPos(player));
magnification = (tempflex * 2.0) + 1.0;
}
else
{
magnification = 4.0;
}
if (magnification < 4.0)
magnification = 4.0;
SetCameraZoom(0, magnification, 150.0);
}
return;
# ........................................................................................
killed:
// Reset the zoom level.
if (player == GetSenderRef())
{
if (greenEffectHandle != -1)
{
freeColorEffect(greenEffectHandle);
greenEffectHandle = -1;
}
SetCameraZoom(0, 1.0, 500.0);
ClearActorFlags(player, 0x20000000);
// Release the player controls.
// if (manualMode)
{
manualMode = 0;
SetActionCog(-1, 0);
}
}
return;
# ........................................................................................
shutdown:
SetCameraZoom(0, 1.0, 500.0);
ClearActorFlags(player, 0x20000000);
return;
end